#ifndef FILECLASS_H_
#define FILECLASS_H_

 class ClFile
 {
  private:
   FILE* phFile_m;
  
  public:
   ClFile(const char* pcchFileName_, const char* pcchMode_)
    {
      phFile_m = fopen(pcchFileName_,pcchMode_);
      if(phFile_m == NULL)
       {
        printf("File %s open error\n",pcchFileName_);
        exit(0);
        return;    
       }
    }

   ~ClFile() { fclose(phFile_m); }
// parameters are where to write read things, how many elements should I read.
   template<typename T> bool Read(T* pSrcBuf_, unsigned int ui32Num_=1)
    {
	   unsigned int ui32Count_ = fread(pSrcBuf_,sizeof(T),ui32Num_,phFile_m);
     if(ui32Count_ != ui32Num_)
      return false;
     else
      return true; 
    }     
// parameters are where to write from, how many elements should I write.
   template<typename T> bool Write(T* pDstBuf_, unsigned int ui32Num_=1)
    {
	   unsigned int ui32Count_ = fwrite(pDstBuf_,sizeof(T),ui32Num_,phFile_m);
     if(ui32Count_ != ui32Num_)
      return false;
     else
      return true; 
    }     
 };
 

#endif /*FILECLASS_H_*/
